package com.ruoyi.tongyan.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tongyan.mapper.TDeclarationMapper;
import com.ruoyi.tongyan.domain.TDeclaration;
import com.ruoyi.tongyan.service.ITDeclarationService;

/**
 * 科研项目申报Service业务层处理
 *
 * @author ruoyi
 * @date 2025-04-09
 */
@Service
public class TDeclarationServiceImpl implements ITDeclarationService
{
    @Autowired
    private TDeclarationMapper tDeclarationMapper;

    /**
     * 查询科研项目申报
     *
     * @param declarationId 科研项目申报主键
     * @return 科研项目申报
     */
    @Override
    public TDeclaration selectTDeclarationByDeclarationId(Long declarationId)
    {
        return tDeclarationMapper.selectTDeclarationByDeclarationId(declarationId);
    }

    /**
     * 查询科研项目申报列表
     *
     * @param tDeclaration 科研项目申报
     * @return 科研项目申报
     */
    @Override
    public List<TDeclaration> selectTDeclarationList(TDeclaration tDeclaration)
    {
        Long userId = SecurityUtils.getUserId() > 1 ? SecurityUtils.getUserId() : null;
        return tDeclarationMapper.selectTDeclarationList(userId,tDeclaration);
    }

    /**
     * 新增科研项目申报
     *
     * @param tDeclaration 科研项目申报
     * @return 结果
     */
    @Override
    public int insertTDeclaration(TDeclaration tDeclaration)
    {
        tDeclaration.setStatu("3");
        String createAccount = SecurityUtils.getUsername();
        Long userId =SecurityUtils.getUserId();
        return tDeclarationMapper.insertTDeclaration(userId,tDeclaration);
    }

    /**
     * 修改科研项目申报
     *
     * @param tDeclaration 科研项目申报
     * @return 结果
     */
    @Override
    public int updateTDeclaration(TDeclaration tDeclaration)
    {
        return tDeclarationMapper.updateTDeclaration(tDeclaration);
    }

    /**
     * 批量删除科研项目申报
     *
     * @param declarationIds 需要删除的科研项目申报主键
     * @return 结果
     */
    @Override
    public int deleteTDeclarationByDeclarationIds(Long[] declarationIds)
    {
        return tDeclarationMapper.deleteTDeclarationByDeclarationIds(declarationIds);
    }

    /**
     * 删除科研项目申报信息
     *
     * @param declarationId 科研项目申报主键
     * @return 结果
     */
    @Override
    public int deleteTDeclarationByDeclarationId(Long declarationId)
    {
        return tDeclarationMapper.deleteTDeclarationByDeclarationId(declarationId);
    }
}
